<?php

namespace Lowpress\PressBundle\Feeds;

use Symfony\Component\DependencyInjection\ContainerInterface;

class MultipleFeedGatherer {

  private $feed_services;

  /**
   * Container
   *
   * @var ContainerInterface
   */
  protected $container;

  /**
   * Initialize tinymce  helper
   *
   * @param ContainerInterface $container
   */
  public function __construct(ContainerInterface $container)
  {
      $this->container = $container;
      $this->feed_services = array();
  }

  /**
   * @return ContainerInterface
   */
  public function getContainer()
  {
      return $this->container;
  }

  function addPressItemConfigurationId($id)
  {
    $gatherer = $this->getContainer()->get($id)->getFeedGatherer();

    $gatherers = is_array($gatherer) ? $gatherer : array($gatherer);

    foreach ($gatherers as $g)
    {
      if ($g instanceof IFeedGatherer)
      {
        $this->feed_services[] = $g;
      }
      else
      {
        throw new \Exception("Feed gatherer must implement IFeedGatherer");
      }
    }
  }

  public function getFeedServices()
  {
    return $this->feed_services;
  }

}